﻿using BattleFury.Server.Wpf.Core.ComponentModel;

namespace BattleFury.Server.Wpf.Models
{
	public class ServerModel
		: NotificationObject
	{
		private string _name;
		private int _port;
		private bool _isConnected;
		private string _motd;

		public string Name
		{
			get { return _name; }
			set
			{
				if (value == _name) return;
				_name = value;
				OnPropertyChanged();
			}
		}

		public int Port
		{
			get { return _port; }
			set
			{
				if (value == _port) return;
				_port = value;
				OnPropertyChanged();
			}
		}

		public string MOTD
		{
			get { return _motd; }
			set
			{
				if (value == _motd) return;
				_motd = value;
				OnPropertyChanged();
			}
		}

		public bool IsConnected
		{
			get { return _isConnected; }
			set
			{
				if (value.Equals(_isConnected)) return;
				_isConnected = value;
				OnPropertyChanged();
				OnPropertyChanged("IsEnabled");
			}
		}

		public bool IsEnabled
		{
			get { return !IsConnected; }
		}

		public ServerModel()
		{
			Name = "Server";
			Port = 28657;
			IsConnected = false;
			MOTD = "Message of the Day";
		}
	}
}